package com.wzx.ptplatform.controller.admin;

import com.wzx.ptplatform.domain.User;
import com.wzx.ptplatform.service.UserService;
import com.wzx.ptplatform.utils.MapUtils;
import io.swagger.annotations.Api;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * @author 紫煦桉
 */
@Api(tags = "管理员模块")
@RestController
public class AdminIndexController {

    final UserService userService;

    public AdminIndexController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("admin_index")
    public ModelAndView adminIndex() {
        return new ModelAndView("admin/index");
    }

    @GetMapping("admin_userInfo")
    public ModelAndView adminUserInfo(String id, Model model) {
        model.addAttribute("admin", userService.findById(Long.parseLong(id)));
        return new ModelAndView("admin/user_info");
    }

    @GetMapping("admin_forgetPassword")
    public ModelAndView adminForgetPassword(String id, Model model) {
        model.addAttribute("admin", new User(Long.parseLong(id)));
        return new ModelAndView("admin/forget_password");
    }

    @PostMapping("admin_reset_password")
    public Map<String, Object> adminResetPassword(String id, String password) {
        Map<String, Object> map = MapUtils.initializeMap();
        if (userService.resetPassword(new User(Long.parseLong(id), password))) {
            MapUtils.successMap(map);
        }
        return map;
    }

    @GetMapping("admin_welcome")
    public ModelAndView adminWelcome() {
        return new ModelAndView("admin/welcome");
    }

    @GetMapping("admin_user_student_message")
    public ModelAndView adminUserStudentMessage() {
        return new ModelAndView("admin/user/student_message");
    }

    @GetMapping("admin_user_company_message")
    public ModelAndView adminUserCompanyMessage() {
        return new ModelAndView("admin/user/company_message");
    }

    @GetMapping("admin_user_university_message")
    public ModelAndView adminUserUniversityMessage() {
        return new ModelAndView("admin/user/university_message");
    }

    @GetMapping("admin_student_resume_message")
    public ModelAndView adminStudentResumeMessage() {
        return new ModelAndView("admin/student/resume_message");
    }

    @GetMapping("admin_student_workExperience_message")
    public ModelAndView adminStudentWorkExperienceMessage() {
        return new ModelAndView("admin/student/work_experience_message");
    }

    @GetMapping("admin_student_projectExperience_message")
    public ModelAndView adminStudentProjectExperienceMessage() {
        return new ModelAndView("admin/student/project_experience_message");
    }

    @GetMapping("admin_student_message_message")
    public ModelAndView adminStudentMessageMessage() {
        return new ModelAndView("admin/student/student_message_message");
    }

    @GetMapping("admin_student_collect_message")
    public ModelAndView adminStudentCollectMessage() {
        return new ModelAndView("admin/student/student_collect_message");
    }

    @GetMapping("admin_company_pt_published_message")
    public ModelAndView adminCompanyPtPublishedMessage() {
        return new ModelAndView("admin/company/pt_published_message");
    }

    @GetMapping("admin_company_pt_unpublished_message")
    public ModelAndView adminCompanyPtUnpublishedMessage() {
        return new ModelAndView("admin/company/pt_unpublished_message");
    }

    @GetMapping("admin_company_pt_work_detail_message")
    public ModelAndView adminCompanyPtWorkDetailMessage() {
        return new ModelAndView("admin/company/pt_work_detail_message");
    }

    @GetMapping("admin_company_received_resume_message")
    public ModelAndView adminCompanyReceivedResumeMessage() {
        return new ModelAndView("admin/company/received_resume_message");
    }

    @GetMapping("admin_university_major_message")
    public ModelAndView adminUniversityMajorMessage() {
        return new ModelAndView("admin/university/major_message");
    }

    @GetMapping("admin_set_province_message")
    public ModelAndView adminSetProvinceMessage() {
        return new ModelAndView("admin/set/province_message");
    }

    @GetMapping("admin_set_city_message")
    public ModelAndView adminSetCityMessage() {
        return new ModelAndView("admin/set/city_message");
    }

    @GetMapping("admin_set_industry_message")
    public ModelAndView adminSetIndustryMessage() {
        return new ModelAndView("admin/set/industry_message");
    }

    @GetMapping("admin_set_job_message")
    public ModelAndView adminSetJobMessage() {
        return new ModelAndView("admin/set/job_message");
    }

    @GetMapping("admin_set_politics_message")
    public ModelAndView adminSetPoliticsMessage() {
        return new ModelAndView("admin/set/politics_message");
    }

}
